import ComponentBase from "./ComponentBase";
import { Logger } from "./Logger";

const { ccclass, property } = cc._decorator;

@ccclass
export default class AdapterComponent extends ComponentBase {

    private widget: cc.Widget;

    onLoad(): void {
        super.onLoad()
        // Logger.log("getSafeAreaRect===", cc.sys.getSafeAreaRect())
        // Logger.log("getSafeAreaRect=toString==", cc.sys.getSafeAreaRect().toString())
        // Logger.log("getSafeAreaRect=width==", cc.sys.getSafeAreaRect().width)
        // Logger.log("getSafeAreaRect==height=", cc.sys.getSafeAreaRect().height)
        // Logger.log("getSafeAreaRect=size==", cc.sys.getSafeAreaRect().size)
        // Logger.log("getSafeAreaRect=x==", cc.sys.getSafeAreaRect().x)
        // Logger.log("getSafeAreaRect==y=", cc.sys.getSafeAreaRect().y)
        // Logger.log("cc.winSize.width", cc.winSize.width)
        // Logger.log("cc.winSize.height", cc.winSize.height)
        this.widget = this.node.getComponent(cc.Widget);
        if (this.widget.isAlignLeft) {
            this.widget.left += cc.sys.getSafeAreaRect().x
        }
        if (this.widget.isAlignRight) {
            this.widget.right += cc.sys.getSafeAreaRect().x
        }
        if (this.widget.isAlignTop) {
            this.widget.top += cc.sys.getSafeAreaRect().y
        }
        if (this.widget.isAlignBottom) {
            this.widget.bottom += cc.sys.getSafeAreaRect().y
        }
    }

}
